<template>
  <div class="detail-page">
    <common-header></common-header>
    <div class="detail">
      <Row>
        <goods-detail :goods="goods"></goods-detail>
      </Row>
      <!--<Row style="margin-top:40px;margin-bottom:20px;">-->
        <!--<goods-title title="评论"></goods-title>-->
        <!--<goods-comment-->
          <!--v-for="comment in comments"-->
          <!--:key="comment.id"-->
          <!--:comment="comment"-->
        <!--&gt;</goods-comment>-->
      <!--</Row>-->
      <!--<Row>-->
        <!--<common-comment :id="+id" @on-add="onAdd"></common-comment>-->
      <!--</Row>-->
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      goods: {},
      id: 0,
      comments: []
    };
  },
  mounted() {
    this.id = this.$route.query.id;
    if (this.id) {
      this.$api.goods.getDetail(this.id).then(data => {
        this.goods = data;
      });
      this.$api.comment.get(this.id).then(data => {
        this.comments = data;
      });
    }
  },
  methods: {
    onAdd(c) {
      this.comments.push(c);
      console.log(this.comments);
    }
  }
};
</script>

<style lang="scss" scoped>
.detail {
  margin: 30px 15%;
  padding: 30px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 0 10px #fff;
  height: 500px;
}
</style>
